package main

import (
	"flag"
	"log"
	"smallnest-rpcx/client"
	"smallnest-rpcx/server"
)

func main() {
	agentType := flag.String("agent", "client", "运行模式: client,server")
	isXClient := flag.Bool("xclient", false, "是否启用xclient")
	isAsync := flag.Bool("async", false, "是否启动异步客户端")
	flag.Parse()

	switch *agentType {
	case "server":
		server.StartDefaultServer()
	case "client":
		i := 1
		if *isAsync == true {
			for i < 10 {
				log.Printf("%d start\n", i)
				if *isXClient {
					client.StartAsyncXClient()
				} else {
					client.StartAsyncClient()
				}
				i++
			}
		} else {
			for i < 10 {
				log.Printf("%d start\n", i)
				if *isXClient {
					client.StartSyncXClient()
				} else {
					client.StartSyncClient()
				}

				i++
			}
		}
	default:
		flag.Usage()
	}
}
